﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using UricaoWeb.LogicaDeNegocios.Reservas;

namespace UricaoWeb.Presentacion
{
    public partial class API_reservar_ConsultarReserva : API_Seguridad_Principal
    {
        private LogicaReservas _logica = new LogicaReservas();

        protected void Page_Load(object sender, EventArgs e)
        {
            var master = Master as MasterPage;
            if (master != null)
            {
                master.actualizar_label();
            }
            base.validar_usuario();
        }

        /// <summary>
        /// Redirecciona a consultar reserva
        /// </summary>
        public static void Show(string message)
        {
            string cleanMessage = message.Replace("'", "\'");
            Page page = HttpContext.Current.CurrentHandler as Page;
            string script = string.Format("alert('{0}');", cleanMessage);
            if (page != null && !page.ClientScript.IsClientScriptBlockRegistered("alert"))
            {
                page.ClientScript.RegisterClientScriptBlock(page.GetType(), "alert", script, true /* addScriptTags */);
            }

        }

        //Verificar
        protected void Button3_Click(object sender, EventArgs e)
        {
            string _habitacion = null;
            string _restaurante = null;
            string _tour = null;
            string _roomService = null;

            if (string.IsNullOrEmpty(tbCodigoReservacion.Text))
            {
                Show("¡ERROR!, ¡Verifique que el codigo de reserva este lleno! y presione nuevamente");
            }
            else
            {
                _habitacion = _logica.ConsultarReservaHabitacion(Int32.Parse(tbCodigoReservacion.Text));
                _restaurante = _logica.ConsultarReservaRestaurante(Int32.Parse(tbCodigoReservacion.Text));
                _tour = _logica.ConsultarReservaTour(Int32.Parse(tbCodigoReservacion.Text));
                _roomService = _logica.ConsultarReservaRoomService(Int32.Parse(tbCodigoReservacion.Text));


                tbCliente.Text = _logica.ConsultarInformacionCliente(Int32.Parse(tbCodigoReservacion.Text));
                tbHabitacion.Text = _habitacion;
                tbRestaurante.Text = _restaurante;
                tbTour.Text = _tour;
                tbRoomService.Text = _roomService;
            }

        }
        protected void BAceptar_Click(object sender, EventArgs e)
        {
            Response.Redirect("http://localhost:11510/Presentacion/Default.aspx");

        }
        protected void BRegresar_Click(object sender, EventArgs e)
        {
            Response.Redirect("http://localhost:11510/Presentacion/Default.aspx");

        }
    }
}